#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int ne[N];
int n, m;
char s[N];
int main()
{
	cin >> n >> m;
	cin >> s + 1;
	/*for (int i = 2, j = 0; i <= n; i++) {
		while (j && s[j] != s[j + 1]) {
			j = ne[j];
		}
		if (s[j] == s[j + 1]) {
			j++;
		}
		ne[i] = j;
	}*/
	for (int i = 2, j = 0; i <= n; i++) {
		while (j && s[i] != s[j + 1]) {
			j = ne[j];
		}
		if (s[i] == s[j + 1]) {
			j++;
		}
		ne[i] = j;
	}
	for (int i = 1; i <= n; i++) {
		cout << ne[i] << " ";
	}
	int len = n - ne[n];
	while (m--) {
		int l, r;
		cin >> l >> r;
		if (l % len == 0 && (r - l + 1) % len == 0 && n % (r - l + 1) == 0) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}